package yanc.app

import grails.transaction.Transactional

@Transactional
class RolesService {

    def ad(Roles role) {
        role.createDate = new Date()
        def length = Roles.count()
        if (length == 0) {
            role.roleId = "1"
        } else {
            role.roleId = length + 1 + ""
        }
        role.save()
        if (!role.save()) {
            role.errors.allErrors.each {
                println it
            }
        }
    }

    def del(Roles role) {
        role.delete()
    }

    def save(Roles role) {
        role.createDate = new Date()
        role.save()
        if (!role.save()) {
            role.errors.allErrors.each {
                println it
            }
        }
    }
}
